<?php
// +----------------------------------------------------------------------
// | 有小象汇 自研正版源码 赋能开发者
// +----------------------------------------------------------------------
// | Copyright (c) 2017~2023 http://www.uxphp.com All rights reserved.
// +----------------------------------------------------------------------
// | Licensed 有小象汇并不是自由软件，未经许可不能去掉有小象汇相关版权
// +----------------------------------------------------------------------
// | Author:  有小象汇
// +----------------------------------------------------------------------

namespace app\adminapi\controller\v1\car;


use app\adminapi\controller\AuthController;
use app\services\car\CarOrderRerentServices;
use think\facade\App;

class CarOrderRerent extends AuthController
{
    public function __construct(App $app,CarOrderRerentServices $services)
    {
        parent::__construct($app);
        $this->services = $services;
    }

    /**
     * 列表
     * @return mixed
     */
    public function getList(){
        $where = $this->request->getMore([
            ['rerent_status',''],
            ['keyword',''],
            ['field_key',''],
            ['pay_type',''],
            ['rerent_status',''],
        ]);
        $admin = $this->request->adminInfo();
        if($admin['store_id']) $where['store_id'] = $admin['store_id'];
        return app('json')->success($this->services->getList($where,true));
    }

    /**
     * 续租详情
     * @return mixed
     */
    public function getRerentInfo(){
        $data = $this->request->getMore([
            ['rerent_id',0],
        ]);
        if(!$data['rerent_id']) return app('json')->fail('参数错误');
        return app('json')->success($this->services->getRerentInfo((int)$data['rerent_id']));
    }
    public function consentApplyFor(){
        $data = $this->request->postMore([
            ['rerent_id',0],
            ['status',20],
        ]);
        $op_user = $this->adminInfo;
        $op_user['user_name'] = $op_user['account'];
        if(!$data['rerent_id']) return app('json')->fail('参数错误');
        return app('json')->success($this->services->consentApplyFor($data,$op_user,3));
    }
}
